//
//  EnemyPrototypes.cpp
//  airfight
//
//  Created by aaron more on 12-9-10.
//  Copyright (c) 2012年 moonriver. All rights reserved.
//

#include <iostream>
#include "EnemyPrototypes.h"


EnemyPrototypes* EnemyPrototypes::s_SharedEnemyPrototypes = NULL;

EnemyPrototypes* EnemyPrototypes::getInstance()
{
    static bool s_bFirstUsePrototypes = true;
    if (NULL == s_SharedEnemyPrototypes) {
        s_SharedEnemyPrototypes = new EnemyPrototypes();
        s_bFirstUsePrototypes = false;
        s_SharedEnemyPrototypes->init();
    }
    return s_SharedEnemyPrototypes;
    
}

EnemyPrototypes::EnemyPrototypes()
{
    enemyPrototype_Dict = NULL;
}

bool EnemyPrototypes::init()
{
    enemyPrototype_Dict = CCDictionary::create();
    enemyPrototype_Dict->retain();
    return true;
}

EnemyPrototypes::~EnemyPrototypes()
{
    CC_SAFE_RELEASE(enemyPrototype_Dict);
}

void EnemyPrototypes::addEnemy(Enemy* p_enemy)
{
    int enemy_id = p_enemy->getFighterId();
    enemyPrototype_Dict->setObject(p_enemy, enemy_id);
}

Enemy* EnemyPrototypes::getEnemyByID(int p_id)
{
    CCObject* tmp = enemyPrototype_Dict->objectForKey(p_id);
    
    if(tmp){
        return (Enemy*)tmp;
    }else{
        return NULL;
    }
}
